//定义初始值
const initalState = {
    count: 10
};

export function counterReducer(state = initalState, action) {
    // console.log(action);
    switch (action.type) {
        case "plus":
            state.count++
            return {
                count: state.count
            };
        case "minus":
            state.count === 0 ? state.count = 0 : state.count--
            return {
                count: state.count
            };
        default:
            return state;
    }
}